<?php

$p = Utils::params();
if(isset($p["logoff"])){
	unset($_SESSION["userid"]);
}
$usrId=false;
if(isset($_SESSION["userid"])){
	$usrId = $_SESSION["userid"];
} else if(isset($p["login"])){
	$usrId = Users::get($p["usr"], $p["pw"]);
}

if($usrId!=false){
	$_SESSION["userid"]=$usrId;
}

if($usrId==false) {
	echo "<form method='post'>Login:<input type='text' name='usr'>&nbsp;Password:<input type='password' name='pw'>&nbsp;<input type='submit' name='login' value='Login'></form>";
	exit(0);
} else {
	$user = DB::load($usrId);
	echo $user->name." <a href='?logoff'>[Logoff]</a>&nbsp;";
}

?>